{extend name="public/header" /}
{block name="body"}
<body>
{include file="public/common" /}
<fieldset class="layui-elem-field site-demo-button" style="padding:30px;">
    <div class="layui-row">
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md12">
            <section class="panel panel-padding">
                <form id="form1" class="layui-form layui-form-pane" action="{:url('')}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">菜单组<i class="fa fa-camera-retro"></i></label>
                        <div class="layui-input-inline">
                            <select class="tpl-form-input" jq-verify="required" jq-error="请选择菜单组" lay-filter="topid" name="topid">
                                <option value="0">顶级菜单</option>
                                {foreach name="menuList" item="vo"}
                                <option value="{$vo.id}" {if condition="$vo.id eq $info.topid"}selected{/if}>{$vo.cname}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">菜单名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" value="{$info.name|default=''}" placeholder="请输入菜单名" class="layui-input">
                        </div>
                    </div>
					<div class="layui-form-item">
                        <label class="layui-form-label">地址url</label>
                        <div class="layui-input-inline">
                            <input type="text" name="url" value="{$info.url|default=''}" placeholder="请输入地址act" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="status" {eq name="info.status" value="1"}checked{/eq} title="正常" value="1" checked />
                            <input type="radio" name="status" {eq name="info.status" value="2"}checked{/eq} title="禁用" value="2" />
                        </div>
                    </div>
					<div class="layui-form-item">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-inline">
                            <input type="text" name="sort" value="{$info.sort|default='0'}" placeholder="请输入排序" class="layui-input">
                        </div>
                    </div>
					<div id="act">
                        <div class="layui-form-item">
                            <label class="layui-form-label">操作内容</label>
                            <button class="layui-btn" id='add_act' type="button">新增</button>
                        </div>
                        {foreach name='info.act' item='vo'}
                        <div class="layui-form-item">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline">
                                <input name="act[{$key}][name]" value="{$vo.name}" placeholder="请输入" class="layui-input " type="text"></div>
                            <label class="layui-form-label">方法</label>
                            <div class="layui-input-inline" style='width: 500px;'>
                                <input name="act[{$key}][act]" value="{$vo.act}" placeholder="请输入" class="layui-input" type="text"></div>
                            <button class="layui-btn layui-btn-danger del_act" onclick="del_act(this)" type="button">-</button>
                        </div>
                        {/foreach}
                    </div>
                    
                    <div class="layui-input-block">
                        <input type="hidden" name="id" type="hidden" value="{$info.id|default=''}">
                        <button lay-submit lay-filter="*" class="layui-btn">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </form>
            </section>
        </div>
    </div>
</fieldset>
</body>
{/block}
{block name="script"}
<script>
var num="{$start_act|default='1'}";
layui.use(['form'], function(){
	var $= layui.jquery;
	$("#add_act").click(function() {
		$("#act").append(
				"<div class='layui-form-item'>" +
				"<label class='layui-form-label'>名称</label>" +
				"<div class='layui-input-inline'>" +
				"<input type='text' name='act["+num+"][name]' value='' placeholder='请输入' class='layui-input '>" +
				"</div>" +
				"<label class='layui-form-label'>方法</label>" +
				"<div class='layui-input-inline' style='width: 500px;'>" +
				"<input type='text' name='act["+num+"][act]' value='' placeholder='请输入' class='layui-input'>" +
				"</div>" +
				"<button class='layui-btn layui-btn-danger del_act'  onclick='del_act(this)' type='button'>-</button>" +
				"</div>");
		num++;
	});
});
function del_act(obj) {
	var $= layui.jquery;
	$(obj).parent().remove();
	num--;
}
</script>
{/block}